﻿
using System;
using Microsoft.Owin.Security;
using Owin;
using Sharp.Platform.Owin.OAuth.QQ;
// ReSharper disable CheckNamespace

namespace Owin
{
    public static class QQAuthenticationExtensions
    {
        public static void UseQQAuthentication(this IAppBuilder app, QQAuthenticationOptions options)
        {
            if (app == null)
            {
                throw new ArgumentNullException(nameof(app));
            }
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            app.Use(typeof(AuthenticationMiddleware), app, options);
        }

        public static void UseQQAuthentication(this IAppBuilder app, string appId, string appSecret)
        {
            UseQQAuthentication(app, new QQAuthenticationOptions()
            {
                AppId = appId,
                AppSecret = appSecret,
                SignInAsAuthenticationType = app.GetDefaultSignInAsAuthenticationType()
            });
        }
    }
}
